package com.jz.netthings.application.bodyCheck.bean;

import lombok.Data;

import java.util.List;

/**
 * @author zyl
 * @Date 2019/4/24 -10:08
 */
@Data
public class MyPage<T> {
    private Integer total;// 总条数
    private Long totalPage;// 总页数
    private List<T> items;// 当前页数据
    private int pageSize=10;//每页显示的条数
    private int currentPageIndex =0;//当前页码
    private int beginIndex =0;//后端分页查询开始条数
    public MyPage() {
    }
    public MyPage(Integer total, List<T> items) {
        this.total = total;
        this.items = items;
    }

    public MyPage(Integer total, Long totalPage, List<T> items) {
        this.total = total;
        this.totalPage = totalPage;
        this.items = items;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = (pageSize==0)?10:pageSize;
    }

    public int getCurrentPageIndex() {
        return currentPageIndex;
    }

    public void setCurrentPageIndex(int currentPageIndex) {
        this.currentPageIndex = currentPageIndex==0?0:currentPageIndex;
    }

    public int getBeginIndex() {
        if(currentPageIndex==0){
            currentPageIndex =1;
        }
        beginIndex = (this.currentPageIndex-1)*pageSize;
        return beginIndex;
    }

    public void setBeginIndex(int beginIndex) {
        this.beginIndex = (this.currentPageIndex-1)*pageSize;
    }
}
